package com.download.web.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.download.web.entity.BusArticleLable;
import com.download.web.entity.model.HotTagsModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author cmy
 * @since 2019-02-20
 */
public interface BusArticleLableMapper extends BaseMapper<BusArticleLable> {

    @Select(value = "SELECT i.`value` from bus_article_lable l " +
            "LEFT JOIN bus_dic_item i on i.id=l.lable_id " +
            "where l.article_id=${id} ")
    List<String> articleLables(@Param("id") Integer artId);

    @Select(value = "SELECT l.lable_id from bus_article_lable l " +
            "where l.article_id=${id} ")
    List<String> selectLables(@Param("id") Integer artId);
    
    @Select(value = "select l.lable_id tagName,count(lable_id) num " +
            " from bus_article_lable l   " +
            " GROUP BY l.lable_id  " +
            " limit ${pageIndex},${pageSize}"  )
    List<HotTagsModel> hotTagsList(@Param("pageIndex") Integer pageIndex, @Param("pageSize") Integer pageSize);

    @Select(value = "select count(1) from  (select l.lable_id tagName,count(lable_id) num  " +
            "    from bus_article_lable l  " +
            "    GROUP BY l.lable_id  " +
            "             ) a"  )
    Integer hotTagsListCount();

}
